package com.gobang.domain.message;

import lombok.*;

/**
 * 心跳消息DTO
 * 服务器向客户端发送的心跳消息
 * 
 * @author System
 * @since 1.0.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class HeartbeatMessage extends WebSocketMessage {
    
    /**
     * 心跳数据
     */
    private HeartbeatData data;
    
    /**
     * 心跳数据内部类
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class HeartbeatData {
        /**
         * 时间戳
         */
        private Long timestamp;
    }
    
    /**
     * 构造函数
     */
    public HeartbeatMessage(HeartbeatData data) {
        super("HEARTBEAT");
        this.data = data;
    }
    
    /**
     * 创建心跳消息
     *
     * @return 心跳消息实例
     */
    public static HeartbeatMessage create() {
        HeartbeatData data = HeartbeatData.builder()
                .timestamp(System.currentTimeMillis())
                .build();
        return new HeartbeatMessage(data);
    }
} 